<template>
  <div class="home">
    <el-container class="container">
      <el-header
        style="background: rgb(59, 169, 224); display: flex;justify-content: space-between; "
      >
        <h3>用户接种预约</h3>
        <div style="display: flex;  ">
          <p>欢迎用户："{{ userData.userId }}" 使用本系统</p>
          <el-button type="danger " style="margin: 8px; " @click="quit"
            >退出</el-button
          >
        </div>
      </el-header>
      <el-container>
        <el-aside style="background: rgb(177, 233, 221);width: 180px;">
          <!-- 菜单 -->
          <el-menu
            :default-active="toMemu"
            class="el-menu-vertical-demo"
            background-color="#00F5FF"
            @select="menuClick"
          >
            <el-menu-item index="/Home/ym-check">
              <span slot="title">疫苗查看</span>
            </el-menu-item>
            <el-menu-item index="/Home/ym-record">
              <span slot="title">接种记录</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-container>
          <el-main>
            <router-view></router-view>
          </el-main>
          <el-footer></el-footer>
        </el-container>
      </el-container>
    </el-container>
  </div>
</template>
<script>
export default {
  components: {},
  data() {
    return {
      toMemu: undefined,
      userData: {}
    };
  },
  methods: {
    menuClick(index, indexPath) {
      this.$router.push(index);
      sessionStorage.setItem("index", index);
      console.log(index, indexPath);
    },
    quit() {
      this.$confirm("确认退出登录", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "退出成功!"
          });
          this.$router.push("/login");
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消登录"
          });
        });
    }
  },
  mounted() {
    this.toMemu = sessionStorage.getItem("index")
      ? sessionStorage.getItem("index")
      : "/Home/ym-check";
    this.userData = JSON.parse(sessionStorage.getItem("userData"));
    console.log(this.userData);
  }
};
</script>
<style lang="less" scoped>
.home {
  height: 100%;
}

.container {
  height: 100%;
}
</style>
